package zy.zy6;

import java.io.*;

public class Test {

    public static void main(String[] args) {
        long start = System.nanoTime();
        try {
            BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\admin\\Desktop\\新建文件夹\\新建文本文档.txt"));
            int i = 0;
            while (br.readLine() != null) {
                i++;
            }
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        long end = System.nanoTime();
        System.out.println("BufferedReader:"+(end - start));
        long start1 = System.nanoTime();
        FileInputStream br1 = null;
        try {
            int j = 0;
            br1 = new FileInputStream("C:\\Users\\admin\\Desktop\\新建文件夹\\新建文本文档.txt");
            byte[] b = new byte[br1.available()];
            int len =0;
            while ((len = br1.read(b)) !=-1) {
                j++;
                String str = new String(b, 0, len);
            }
            br1.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        long end1 = System.nanoTime();
        System.out.println("查找byte:"+(end1 - start1));
    }
    }
